#include<bits/stdc++.h>
using namespace std;
struct sb{
	int num;
	int kind;
}a[2][200002];int b,c=0,d,e=1,f=1,g;stack<sb>h;
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&b);
	for(int i=1;i<=b;i++){
		scanf("%d",&a[0][i].kind);
		a[0][i].num=i;a[0][i].kind++;
	}g=b+1;
	while(a[0][b].kind){
		for(int i=g-1,g=1;i>=1;i--){
			if(a[0][i].kind!=0&&a[0][i].kind!=a[0][i-1].kind){
				h.push(a[0][i]);
				a[0][i].kind=0;
			}
			else a[1][g++]=a[0][i];
		}
		while(!h.empty()){
			printf("%d ",h.top().num);
			h.pop();
		}printf("\n");
		for(int i=1;i<g;i++){
			a[0][g-i]=a[1][i];
			a[1][i]={0,0};
		}
	}return 0;
} 
